require(['grid', 'topBar','date'], function () {
    $('#top').topBar({
        left: [
               {
                   type: 'filter',
                   search: function () {
                	   search();
                   },
                   item: [
                        {
                            text: '停车场',
                            name: 'parkingLotCd',
                            type: 'item-select',
                            url : "/sysParking/getParkingInfoListByOrgId.htm",
                            key:'parkingLotCd',
                            value:'parkingLotName',
                            data: [
                                {text: '全部', value: 'All'}
                            ]
                       }
                   ]
               }
        ]        
    });

    $('#grid1').grid({
    	url : "/sysParking/searchParkingLotCarTotalPage.htm",
		multiselect:false,
		colModel:[
		    {name: "parkingLotName", label:"停车场", width:"120"},
			{name: "lineName", label:"运营线路", width:"120"},
			{name: "carCnt", label:"车辆数", width:"120"}]		
    });
    
    $('#grid2').grid({
    	url : "/sysParking/searchParkingLotCarDetailPage.htm",
		multiselect:false,
		colModel:[
		    {name: "parkingLotName", label:"停车场", width:"120"},
			{name: "lineName", label:"运营线路", width:"120"},
			{name: "licPltNo", label:"车牌号", width:"120"},
			{name: "inoutTime", label:"入场时间", width:"130"}]		
    });
    
    function search(){
    	var $postData={};
 	           $postData=$("#top").parent().getValues();
       var nodes = commonFun.getLeftTreeCheckedNodes();
       if(nodes){
    	   //commonFun.getLeftTreeCheckedNodes('CAR')
    	   if(nodes.CAR){//是否包含carIds
    		   $postData.orgIds = nodes.CAR.toString();
    		   $postData.type='CAR';
    		}
    	   else{
    		   $postData.orgIds = '';
    		   $postData.type='';
    	   }
       }
       $('#grid1').grid('setGridParam', {
           datatype: "json",
           postData: $postData
       }).trigger("reloadGrid");
       $('#grid2').grid('setGridParam', {
           datatype: "json",
           postData: $postData
       }).trigger("reloadGrid");
    }
})
